package de.gameduell.framework.test {
	import de.gameduell.framework.security.SecureNumber;
	import de.gameduell.framework.util.FlashVars;

	public class TestMode {
	
		private static const WIN:String = "win";
		private static const WIN_SCORE:int = 10;
		private static const LOSE_SCORE:int = 0;
		private var _enabled:Boolean = false;
		private static var instance:TestMode;
		private var _type:String;

		public static function getInstance():TestMode {
			if(instance == null) {
				instance = new TestMode();
			}
			return instance;
		}

		public function TestMode() {
			_enabled = FlashVars.getKeyValue(FlashVars.TESTMODE) != FlashVars.NO_VALUE;
			_type = FlashVars.getKeyValue(FlashVars.TESTMODE);
			
		}
		
		public function get enabled():Boolean {
			return _enabled;
		}
		
		public function get type():String {
			return _type;
		}
		
		public function get scoreAsInt():int {
			return type == WIN ? WIN_SCORE : LOSE_SCORE;
		}

		public function get scoreAsString():String {
			return type == WIN ? String(WIN_SCORE) : String(LOSE_SCORE);
		}
		
		public function get scoreAsSecureNumber():SecureNumber {
			return type == WIN ? new SecureNumber(WIN_SCORE) : new SecureNumber(LOSE_SCORE);
		}
	}
}
